package com.vito.oa.email.impl;

import java.util.Comparator;

import javax.mail.Message;
import javax.mail.MessagingException;

/**
 * 邮件按时间倒序
 * @author wangjie
 *
 */
public class OaMessageComparator implements Comparator<Message>{

	public int compare(Message arg0, Message arg1) {
		boolean isBefore = false;
		try {
			if(arg0.getSentDate() != null && arg1.getSentDate() != null) {
				isBefore = arg0.getSentDate().before(arg1.getSentDate());
			}
		} catch (MessagingException e) {
			e.printStackTrace();
		}
		int rntValue = 0;
		if (isBefore) {
			rntValue = 1;
		} else {
			rntValue = -1;
		}
		return rntValue;
	}
}
